package com.by.basicweb.config;

import jakarta.validation.Validation;
import jakarta.validation.Validator;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class ParameterValidationConfig {

    @Bean
    public Validator validator(){
        return Validation.byProvider(HibernateValidator.class)
                .configure()
                // 快速失败，有一个参数校验失败，立马抛异常
                .failFast(true)
                .buildValidatorFactory()
                .getValidator();

    }

}
